<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>回收小分类</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<input type="hidden" id="recordId" name="recordId" value="${recordId}" />
	<input type="hidden" id="id" name="id" value="${recoverySackDetail.id}" />

	<!--<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;物品</label>
		<div class="layui-input-block">
			<select class="form-control" name="catId" lay-filter="catId" lay-verify="required" id="catId"></select>
		</div>
	</div>

	-->

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;物品</label>
		<div class="layui-input-block">
			<input type="hidden" name="catId" id="catId" value="${recoverySackDetail.catId}" />
			<input type="text" class="layui-input" id="catName" value="${recoverySackDetail.catName}" placeholder="请选择物品" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;名称</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="catName" value="${recoverySackDetail.catName}" placeholder="请输入名称" lay-verify="required" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			&nbsp;&nbsp;价格</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="catPrice" value="${recoverySackDetail.catPrice}" placeholder="请输入价格" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;数量</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="catNum" value="${recoverySackDetail.catNum}" placeholder="请输入数量" lay-verify="required" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
			<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button></div>
	</div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['form', 'jquery', 'baseUtil','fileUtil', 'pageUtil','dialogUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
            baseUtil = layui.baseUtil,
            dialogUtil = layui.dialogUtil,
            fileUtil = layui.fileUtil,
            pageUtil = layui.pageUtil;

        var id = '${recoverySackDetail.id}';

        $("#catName").bind('click',function () {
            dialogUtil.popUpSingleSelect("选择器","/recoveryLargeCat/dTreeList",function(id,name,layer,index){
                $("#catId").val(id);
                $("#catName").val(name);
                setCat(id);
            });
        });

        var catId = '${recoverySackDetail.catId}';
        if (catId != null && catId != "") {
            setCat(catId);
		}

		function setCat(catId){
            baseUtil.postMethod("/recoveryMiddleCat/getRecoveryMiddleCatById",{
                id : catId
            },function (result) {
                if(0==result.code){
                    //成功
                    var smallCat = result.data;
                    $("input[name='catName']").val(smallCat.name);
                    $("input[name='catPrice']").val(smallCat.price);
                }else{
                    top.layer.msg(result.msg);
                }
            });
		}

        form.on('submit(submitBtn)',
            function(data) {
				if (data.field.price == null || data.field.price == ""){
					data.field.price = 0;
				}
                baseUtil.postMethodResult("/recoverySackDetail/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });</script>
</body>

</html>